<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增客户拜访日志')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-log-add">
            <input name="customerNo" class="form-control" type="hidden" th:value="${sysOaCustomer.customerNo}" >
            <div class="form-group">    
                <label class="col-sm-3 control-label ">拜访客户：</label>
                <div class="col-sm-8">
                    <input name="customerName" class="form-control" type="text" readonly th:value="${sysOaCustomer.customerName}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">拜访类型：</label>
                <div class="col-sm-8">
                    <select name="visitType" class="form-control m-b" th:with="type=${@dict.getType('sys_customer_visit_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">拜访时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="visitTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">拜访人：</label>
                <div class="col-sm-8">
                    <input name="visitLinkUser" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-8">
                    <input name="visitLinkPhone" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">拜访内容：</label>
                <div class="col-sm-8">
                    <textarea name="visitContent" class="form-control" required></textarea>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">拜访结果：</label>
                <div class="col-sm-8">
                    <textarea name="visitResult" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="visitUrl">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="visitUrl" name="file" type="file">
                    </div>
                </div>
            </div>
          <div class="form-group">
                <label class="col-sm-3 control-label">推送人：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input class="form-control" type="hidden" name="acceptUser"  id="transitionPerson" required>
                        <input class="form-control" type="text" name="transitionPersonName" onclick="selectUserInfo()" id="transitionPersonName" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix ="/system/customer"
        $("#form-log-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/visitAdd", $('#form-log-add').serialize());
            }
        }

        $("input[name='visitTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").fileinput({
            uploadUrl: '/common/upload',
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        /*选择用户*/
        function selectUserInfo() {
            var url = "/system/resign/selectUser";
            $.modal.open("选择用户",url,"","",doSubmit);
        }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            var iframeWin = layero.find('iframe')[0];
            iframeWin.contentWindow.submitHandler(index, layero);
            $("#transitionPerson").val(body.find('#id').val());
            $("#transitionPersonName").val(body.find('#userName').val());
            layer.close(index);
        }
    </script>
</body>
</html>